import request from '@/utils/request'

/** 上传下载API开始 */
export function addFolder(id, originalFilename, parentId) {
  return request({
    url: '/api/file/file/addFolder',
    method: 'post',
    params: {
      id: id,
      originalFilename: originalFilename,
      parentId: parentId
    }
  })
}
export function queryFileTypeName() {
  return request({
    url: '/api/file/file/queryFileTypeName',
    method: 'get'
  })
}
export function uploadFile(data) {
  return request({
    url: '/api/file/file/uploadFile',
    method: 'post',
    needLoading: true,
    data
  })
}

export function downloadFile(data) {
  return request({
    url: '/api/file/file/downloadFile',
    method: 'post',
    needLoading: true,
    responseType: 'blob',
    data
  })
}
/** 上传下载API结束 */
/** 文件仓储API开始 */
export function addSysFileStorage(data) {
  return request({
    url: '/api/file/sysfilestorage/addSysFileStorage',
    method: 'post',
    needLoading: true,
    data
  })
}

export function updateSysFileStorage(data) {
  return request({
    url: '/api/file/sysfilestorage/updateSysFileStorage',
    method: 'put',
    needLoading: true,
    data
  })
}
export function deleteSysFileStorageById(data) {
  return request({
    url: '/api/file/sysfilestorage/deleteSysFileStorageById',
    method: 'post',
    params: {
      id: data
    }
  })
}
/** 文件仓储API结束 */
/** 文件管理API开始 */
export function dirCommand(data) {
  return request({
    url: '/api/file/sysfile/dirCommand',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' },
    method: 'post',
    needLoading: true,
    data
  })
}
export function fileCommand(data) {
  return request({
    url: '/api/file/sysfile/fileCommand',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' },
    method: 'post',
    needLoading: true,
    data
  })
}
export function downloadCommand(data) {
  return request({
    url: '/api/file/sysfile/downloadCommand',
    method: 'get',
    needLoading: true,
    responseType: 'blob',
    params: data
  })
}
export function findDirTree(data) {
  return request({
    url: '/api/file/sysfile/findDirTree',
    method: 'get',
    needLoading: true,
    params: data
  })
}
export function copyMoveCommand(data) {
  return request({
    url: '/api/file/sysfile/copyMoveCommand',
    method: 'post',
    needLoading: true,
    data
  })
}
export function searchFile(query) {
  return request({
    url: '/api/file/sysfile/searchFile',
    method: 'get',
    params: query
  })
}
export function findSysFileHistoryByFileId(data) {
  return request({
    url: '/api/file/sysfilehistory/findSysFileHistoryByFileId',
    method: 'get',
    params: data
  })
}

/** 文件理API结束 */
